"""
匿名函数：没有名字的函数
应用场景：函数结构简单，无序声明直接使用
语法：lambda 参数列表：语句逻辑块
"""

sum = lambda  x,y: x+y
res = sum(3,4)
print(res)

# lambda 嵌套if else
res1 =  lambda x: x+1 if x > 0 else x-1
print(res1(3))
print(res1(-3))

# 正数在前，负数在后,正数由小到大排序，负数逆序排序
ls = [1,3,-2,4,-8,-3,11,8,-5,9]
z_ls = []
f_ls = [] 

for x in ls:
    if x>0:
        z_ls.append(x)
    else:
        f_ls.append(x)

z_ls.sort()
f_ls.sort(reverse=True)
new_ls = z_ls + f_ls
print(new_ls)

